#ifndef OGGLENGTH_OGGLENGTH_H_INCLUDED_
#define OGGLENGTH_OGGLENGTH_H_INCLUDED_

#include "lhcutils/IStream.h"

namespace ogglength
{

// Gets the length in seconds of an Ogg Vorbis file that will be reported by most media players and utilities.
// The stream must be readable and seekable.
// Throws: IoException, OggVorbisException
double GetReportedTime(lhcutils::IStream& oggStream);

// Gets the real length in seconds of an Ogg Vorbis file. This can differ from the reported length if the file has
// been tampered with (like what this program does :)
// The stream must be readable and seekale.
// Throws: IoException, OggVorbisException
double GetRealTime(lhcutils::IStream& oggStream);

// Sets the reported length of an Ogg Vorbis file in seconds.
// This is done by changing the granule position field of the last Ogg page.
// The file must be a normal Ogg Vorbis file (1 logical bitstream).
// The stream must be readable, writeable, and seekable.
// Throws: OggVorbisException for various error conditions, including the file not being an Ogg Vorbis file,
// or the file appearing to be corrupt.
// Throws: IoException
// If the function returns without throwing an exception, it succeeded.
void ChangeSongLength(lhcutils::IStream& oggStream, double numSeconds);

}

#endif

/*
 Copyright 2011 Greg Najda

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
